home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
util
/
cdity
/
Yak210src.lha
/
Yak_2.10_Src
/
handlers.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-19
|
27KB
|
1,047 lines
/*
* Handlers.c
*
* This module contains the input handlers set up by Yak.
*
* The main handler is for autopointing, keyactivation, keyclicking and blanking
* There's are 3 specialized handlers for mouse cycling functions : WindowToFront,
* WindowToBack, and ScreenCycling.
*
*/
#define __USE_SYSBASE
#include <exec/types.h>
#include <exec/exec.h>
#include <devices/console.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <libraries/commodities.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/displayinfo.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/layers.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/commodities.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include "code.h"
#include "yak.h"
#include "Settings.h"
#include "Handlers.h"
#include "hotkey_types.h"
#ifdef PREFS
# define CATCOMP_NUMBERS
# include "yak_locale_strings.h"
# include "Requesters.h"
#else
# ifndef CONV
# include "Beep.h"
# include "LastActiveWindow.h"
# endif
#endif
static char ExcludeWbWindowPattern[20]; /* Normally it takes 13 bytes */
YakHandler MouseCyclingHandlers[NUM_HANDLERS] = {
{ NULL, NULL, 0, 0, 0, 0, NULL, "", NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL, "", NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL, "", NULL}
};
YakHandler DEF_MOUSECYCLING[NUM_HANDLERS]= {
{ NULL, WindowToFrontHandler, YKHK_INACTIVE, WINDOW_TOFRONT_EVENT, DEF_TOFRONT_CLICKS , DEF_TOFRONT_OPTIONS , DEF_TOFRONT_HOTKEY , DEF_SCREENPATTERN },
{ NULL, WindowToBackHandler , YKHK_INACTIVE, WINDOW_TOBACK_EVENT, DEF_TOBACK_CLICKS , DEF_TOBACK_OPTIONS , DEF_TOBACK_HOTKEY , DEF_SCREENPATTERN },
{ NULL, ScreenCyclingHandler, YKHK_INACTIVE, SCREENCYCLING_EVENT, DEF_SCREENCYCLING_CLICKS, DEF_SCREENCYCLING_OPTIONS, DEF_SCREENCYCLING_HOTKEY, DEF_SCREENPATTERN }
};
VOID
CleanMouseCycling(void)
{
register int i;
for (i=0; i<NUM_HANDLERS; i++)
{
if (MouseCyclingHandlers[i].ScreenPatternData.pat)
{
FreeVec(MouseCyclingHandlers[i].ScreenPatternData.pat);
MouseCyclingHandlers[i].ScreenPatternData.pat=NULL;
}
if (MouseCyclingHandlers[i].KeyDef)
{
FreeVec(MouseCyclingHandlers[i].KeyDef);
MouseCyclingHandlers[i].KeyDef=NULL;
}
/* DeleteCxObjAll() works even with NULL argument */
DeleteCxObjAll(MouseCyclingHandlers[i].CxObj);
MouseCyclingHandlers[i].CxObj=NULL;
}
}
VOID
InitMouseCyclingPatterns (VOID)
{
UBYTE i;
for (i=0; i<NUM_HANDLERS; i++)
{
InitPattern(MouseCyclingHandlers[i].ScreenPatternData.patstr,
&MouseCyclingHandlers[i].ScreenPatternData);
}
#if !defined(PREFS) && !defined(CONV)
/* Initialize the pattern to exclude Wb window for Window_To_Front */
ParsePattern("~(Workbench)", ExcludeWbWindowPattern, 20);
#endif
}
/*
* CompatibleParseIX - frontend to ParseIX() to allow compatibility of V38+
* commodity.library hotkey definitions with V37 library.
*/
long
CompatibleParseIX(char *I_Description, IX *ix)
{
char *pos=NULL;
UBYTE c, begin;
long failurecode = 0l;
UWORD code = 0;
char *description;
if (I_Description == NULL)
{
failurecode = -2;
}
else
{
/* Skip blank spaces in a 68000 compatible way, avoid odd addresses */
begin = 0;
while (I_Description[begin] == ' ')
{
begin++;
}
if (CxBase->lib_Version < 38L) /* COMMODITIES_V37 */
{
description = AllocVec(strlen(I_Description)+1-begin, MEMF_CLEAR);
for (c=begin; c<strlen(I_Description); c++)
description[c-begin] = tolower(I_Description[c]);
/*
* parse and remove keywords that are not supported
* by V37 commodities.library
*
*/
if (pos = strstr(description, " mouse_leftpress"))
{
code = IECODE_LBUTTON;
}
else
{
if (pos = strstr(description, " mouse_rightpress"))
{
code = IECODE_RBUTTON;
}
else
{
if (pos = strstr(description, " mouse_middlepress"))
{
code = IECODE_MBUTTON;
}
}
}
if (pos) /* RawMouse class */
{
/* Put an end to our description before unsupported keywords
* but avoid odd address for 68000
*/
description[(LONG)pos - (LONG)description]= '\0';
}
failurecode = ParseIX((UBYTE *)description, ix);
/*
* now change ix for our new keywords
*
*/
if (code)
{
/*
* change code
*
*/
if (ix->ix_Class != IECLASS_RAWMOUSE)
failurecode = -1;
else
ix->ix_Code = code;
/*
* change also QualMask for mouse buttons
*
*/
ix->ix_QualMask |= IEQUALIFIER_MIDBUTTON | IEQUALIFIER_RBUTTON | IEQUALIFIER_LEFTBUTTON;
/*
* parse for qualifiers the use wants to be considered irrelevant
*
*/
if (strstr(description, "-leftbutton")) ix->ix_QualMask &= ~IEQUALIFIER_LEFTBUTTON;
if (strstr(description, "-midbutton")) ix->ix_QualMask &= ~IEQUALIFIER_MIDBUTTON;
if (strstr(description, "-rbutton")) ix->ix_QualMask &= ~IEQUALIFIER_RBUTTON;
}
FreeVec(description);
}
else /* COMMODITIES_V38+ */
{
/* Use the definition as is */
failurecode = ParseIX((UBYTE *)I_Description, ix);
}
if (!failurecode)
{
/* Patch ParseIX() up */
if (ix->ix_Class == IECLASS_RAWMOUSE)
{
if (ix->ix_Code == IECODE_LBUTTON) ix->ix_Qualifier |= IEQUALIFIER_LEFTBUTTON;
if (ix->ix_Code == IECODE_MBUTTON) ix->ix_Qualifier |= IEQUALIFIER_MIDBUTTON;
if (ix->ix_Code == IECODE_RBUTTON) ix->ix_Qualifier |= IEQUALIFIER_RBUTTON;
}
ix->ix_QualMask |= ix->ix_Qualifier;
}
}
return(failurecode);
}
#if !defined(PREFS) && !defined(CONV)
void TurnMouseOn (void);
static void TurnMouseOff (void);
static __regargs void IntuiOp (void (*routine) (APTR), APTR parameter);
static __regargs void PopToFront (struct Window *win);
static __regargs BOOL StrGadgetActive (struct Window *w);
extern __far struct Custom custom;
#define REBLANKCOUNT 10 /* how long to wait to reblank mouse */
#define TURN_OFF_SPRITES {OFF_SPRITE;custom.spr[0].dataa = custom.spr[0].datab = 0;}
void (*intui_routine) (APTR); /* for intui_op's */
APTR intui_parameter;
CxObj *clickobj;
ULONG clicksigflag, intuiopsigflag, blankscreensigflag, depthscreensigflag;
static BYTE clicksigbit, blankscreensigbit, depthscreensigbit, intuiopsigbit = -1;
static BOOL misspop;
/* for screen cycling */
STACKARGS void
MyScreenToBack (struct Screen *scr)
{
RememberActiveWindow(NULL);
ScreenToBack (scr);
ActivateMouseWindow (SCREEN);
}
STACKARGS void
MyScreenToFront (struct Screen *scr)
{
RememberActiveWindow(NULL);
ScreenToFront (scr);
ActivateMouseWindow (SCREEN);
}
/* Stub for Intuition routines - passes request on to main task.
* DO NOT CALL WHILE FORBID()ING!
* Thanks to Eddy Carroll for this.
*/
#define WTB(win) IntuiOp(WindowToBack, win)
#define WTF(win) IntuiOp(WindowToFront, win)
#define WACT(win) IntuiOp((void (*)(APTR))ActivateWindow, win)
#define STB(scr) IntuiOp(MyScreenToBack, scr)
#define STF(scr) IntuiOp(MyScreenToFront, scr)
BYTE oldpri; /* used by main.c */
static struct Task *YakTask;
static __regargs void
IntuiOp (void (*routine) (APTR), APTR parameter)
{
oldpri = SetTaskPri (YakTask, 21);
intui_routine = routine;
intui_parameter = parameter;
Signal (YakTask, intuiopsigflag);
}
/* pattern-matching on screen/window titles */
#define IsXXXScreen(scr, pat) (scr && (!scr->DefaultTitle || MatchPattern(pat, scr->DefaultTitle)))
#define IsAutoScreen(scr) IsXXXScreen(scr, autoscrpat)
#define IsXXXWindow(win, pat) (!win->Title || MatchPattern(pat, win->Title))
#define IsPopWindow(win) IsXXXWindow(win,popwinpat)
#define IsNotWbWindow(win) (!win->Title || MatchPattern(ExcludeWbWindowPattern, win->Title))
#define IsIncludedScreen(scr,handler) IsXXXScreen(scr, handler.ScreenPatternData.pat)
/* when is a window safe to bring to front and not already at front? */
#define OkayToPop(win) (!win->ReqCount && !(win->Flags & (WFLG_MENUSTATE|WFLG_BACKDROP)) \
&& win->WLayer->ClipRect && win->WLayer->ClipRect->Next)
/* WindowToFront only if no requester, not backdrop, not already front... */
static __regargs void
PopToFront (struct Window *win)
{
/* want to avoid popping immediately after mousebutton/keyboard */
if (misspop)
{
misspop = FALSE;
}
else
{
if (OkayToPop (win))
{
/* Does it pass pattern? */
if (IsPopWindow (win))
{
WTF (win); /* We use signals to reduce time spent in the input device */
}
}
}
}
/* modified from DMouse */
/* expects multitasking to be Forbid()en */
static struct Screen *mousescr; /* the screen under the mouse */
struct Screen *
ScreenUnderMouse( void )
{
struct Screen *scr;
ULONG lock;
lock = LockIBase(0);
for (scr = IntuitionBase->FirstScreen;
scr && scr->TopEdge > 0 && scr->MouseY < 0;
scr = scr->NextScreen);
UnlockIBase(lock);
return(scr);
}
struct Window *
WindowUnderMouse( void )
{
struct Layer *layer = NULL;
ULONG lock;
lock = LockIBase(0);
for (mousescr = IntuitionBase->FirstScreen;
mousescr && mousescr->TopEdge > 0 && mousescr->MouseY < 0;
mousescr = mousescr->NextScreen);
UnlockIBase(lock);
if (mousescr)
layer = WhichLayer(&mousescr->LayerInfo, mousescr->MouseX, mousescr->MouseY);
return (layer ? (struct Window *) layer->Window : NULL);
}
/* does active window have an active string gadget? */
static __regargs BOOL
StrGadgetActive (struct Window *w)
{
struct Gadget *g = w->FirstGadget;
for (; g; g = g->NextGadget)
if ((g->GadgetType & STRGADGET) && (g->Flags & GFLG_SELECTED))
return TRUE;
return FALSE;
}
/* activate window under mouse */
/* context sensitive; why tells routine how to behave */
/* can be AUTO, KEY, SCREEN, RMBACT */
__regargs void
ActivateMouseWindow (BYTE why)
{
struct Window *win = NULL, *IB_ActiveWindow;
ULONG lock;
if ((why != SCREEN) || scractivate)
{
if (why == SCREEN)
{
win = LastActiveWindow(ScreenUnderMouse());
}
if (!win)
win = WindowUnderMouse ();
if (win) /* window exists to activate */
{
/* either window is not active or auto-activating - need to pop? */
if (win->Flags & WFLG_WINDOWACTIVE) /* already active - needs popped? */
{
if (why == AUTO && autopop && IsAutoScreen (win->WScreen))
{
PopToFront (win);
}
}
else if (why != AUTO || IsAutoScreen (win->WScreen))
{
/* window is not active, should we try to activate it? */
lock = LockIBase(0);
IB_ActiveWindow = IntuitionBase->ActiveWindow;
UnlockIBase(lock);
if (!IB_ActiveWindow ||
!(IB_ActiveWindow->Flags & WFLG_MENUSTATE) && /* not showing menus */
!(why == KEY && StrGadgetActive (IB_ActiveWindow))) /* no str gad active */
{
/* do autopop? */
if (why == AUTO && autopop)
PopToFront (win);
if (why == KEY)
ActivateWindow (win); /* need this to avoid losing keys */
else
WACT (win); /* ...activate window */
RememberActiveWindow(win);
}
}
}
else
{
lock = LockIBase(0);
IB_ActiveWindow = IntuitionBase->ActiveWindow;
UnlockIBase(lock);
if (scractivate && mousescr && mousescr->FirstWindow &&
((why == SCREEN) ||
(why == RMBACT && IB_ActiveWindow && IB_ActiveWindow->WScreen != mousescr)))
{
WACT (mousescr->FirstWindow); /* ...activate window */
RememberActiveWindow(mousescr->FirstWindow);
}
}
}
}
static __chip UWORD posctldata[4];
static struct SimpleSprite simplesprite =
{posctldata, 0, 0, 0, 0};
static BOOL mouseoff; /* is mouse off? (MB_SPRITES only) */
void
TurnMouseOn () /* restore mouse-pointer */
{
if (mouseblank == MB_SPRITES) /* really dirty blanking */
{ /* but guaranteed to work... */
if (mouseoff)
{
Forbid ();
WaitTOF ();
ON_SPRITE;
Permit ();
}
}
else
{
RethinkDisplay();
}
mouseoff = FALSE;
}
static void
TurnMouseOff () /* blank mouse-pointer */
{
if (!mouseoff) /* no point in turning it off twice... */
{
Forbid ();
if (mouseblank == MB_SPRITES)
{
WaitTOF ();
OFF_SPRITE;
custom.spr[0].dataa = custom.spr[0].datab = 0;
}
else
{
ChangeSprite(NULL, &simplesprite, (APTR)posctldata);
}
Permit ();
mouseoff = TRUE;
}
}
BOOL blanked;
static struct Screen *blankscr;
void
BlankScreen ()
{
if (screenblank == SB_DMA)
{
/* Turn DMA off */
custom.dmacon = BITCLR|DMAF_RASTER|DMAF_COPPER|DMAF_SPRITE;
blanked = TRUE;
}
else
{
ULONG modeid = INVALID_ID;
if (blankscr)
ScreenToFront (blankscr);
else
{
Forbid ();
if (IntuitionBase->FirstScreen)
modeid = GetVPModeID (&(IntuitionBase->FirstScreen->ViewPort));
Permit ();
if (modeid == INVALID_ID)
modeid = LORES_KEY;
if (blankscr = OpenScreenTags (NULL, SA_Depth, 1,
SA_Title, "Yak blanking screen",
SA_Quiet, TRUE,
SA_Behind, TRUE,
SA_DisplayID, modeid,
TAG_DONE))
{
SetRGB4 (&blankscr->ViewPort, 0, 0, 0, 0);
ScreenToFront (blankscr);
blanked = TRUE;
}
}
/* Blank all the sprites */
TURN_OFF_SPRITES;
}
/* Blank mouse in case OFF_SPRITE or DMA off didn't work (case of PICASSO II board) */
TurnMouseOff();
}
void
UnBlankScreen ()
{
if (screenblank == SB_DMA)
{
/* Turn DMA on */
custom.dmacon = BITSET|DMAF_RASTER|DMAF_COPPER|DMAF_SPRITE;
}
else
{
if (blankscr)
CloseScreen (blankscr);
blankscr = NULL;
blanked = FALSE;
ON_SPRITE;
}
/* UnBlank mouse in case ON_SPRITE or DMA on didn't work (case of PICASSO II board) */
TurnMouseOn();
}
#define ALL_BUTTONS (IEQUALIFIER_LEFTBUTTON|IEQUALIFIER_RBUTTON|IEQUALIFIER_MIDBUTTON)
#define KEY_QUAL (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT \
|IEQUALIFIER_CONTROL \
|IEQUALIFIER_LALT|IEQUALIFIER_RALT \
|IEQUALIFIER_LCOMMAND|IEQUALIFIER_RCOMMAND)
#define ALL_QUALS (ALL_BUTTONS|KEY_QUAL)
/*
* MainHandler is an input handler with no filter attached, it sees everything
* and so can manage keyactivation, autopointing, keyclicking and blanking
*/
SAVEDS void
MainHandler (CxMsg * CxMsg, CxObj * CO)
{
static WORD apcount; /* timer events since last mousemove */
struct InputEvent *ev;
ev = (struct InputEvent *) CxMsgData (CxMsg);
switch (ev->ie_Class)
{
case IECLASS_TIMER: /*** AUTO-ACTIVATE/POP, SCREENBLANK, MOUSEBLANK ***/
if (!(ev->ie_Qualifier & ALL_QUALS) && autopoint && !apcount--)
{
ActivateMouseWindow (AUTO);
}
if (screenblank && !--blankcount) /* blank screen? */
{
/* Don't blank screen while we are still in the input.device processing */
/* Take care of screen mode promotors that open requesters */
Signal (YakTask, blankscreensigflag);
blankcount = blanktimeout; /* reset counter */
} /* in case screen opens on top */
if (mouseblank && !--mblankcount) /* blank mouse? */
{
mouseoff = FALSE; /* force reblank */
TurnMouseOff ();
/* in case someone else turns it on, reset counter */
mblankcount = REBLANKCOUNT;
}
break;
case IECLASS_RAWKEY:
if (!(ev->ie_Code & IECODE_UP_PREFIX))
{
/*** MOUSEBLANK, KEYACTIVATE, KEYCLICK ***/
blankcount = blanktimeout; /* reset blanking countdown */
if (blanked) /* turn off screen-blanking */
UnBlankScreen ();
if (mouseblank)
{
if (ev->ie_Qualifier & (IEQUALIFIER_LCOMMAND | IEQUALIFIER_RCOMMAND))
{
/* this allows use of keyboard to move mouse and to access menus */
mblankcount = mblanktimeout;
TurnMouseOn ();
}
else
{
if (blankmouseonkey)
{
TurnMouseOff (); /* blank the mouse */
}
}
}
if (click_volume && !(ev->ie_Qualifier & IEQUALIFIER_REPEAT))
Signal (YakTask, clicksigflag);
if (!(ev->ie_Qualifier & ALL_BUTTONS) && keyactivate) /* perform key-activate */
ActivateMouseWindow (KEY);
}
break;
case IECLASS_RAWMOUSE:
/* restore screen/mouse pointer */
blankcount = blanktimeout; /* reset blanking countdowns */
mblankcount = mblanktimeout;
if (blanked) /* turn off screen-blanking */
UnBlankScreen ();
if (mouseoff)
TurnMouseOn (); /* not needed for MB_COPPER */
/* maybe should check for depth gadgets? nah... */
if (!(ev->ie_Qualifier & KEY_QUAL))
{
if (!(ev->ie_Qualifier & ALL_BUTTONS))
{
apcount = autopoint_delay; /* reset auto-activate count */
}
else
{
misspop = TRUE;
apcount = -1; /* button - wait for move */
if ((rmbactivate && (ev->ie_Code == IECODE_RBUTTON)) ||
(mmbactivate && (ev->ie_Code == IECODE_MBUTTON)))
{
ActivateMouseWindow (RMBACT);
}
if (ev->ie_Code == IECODE_LBUTTON)
{
struct Window *win = WindowUnderMouse();
if (win == NULL)
{
/* Check for screen depth gadget */
struct Screen *screen = ScreenUnderMouse();
struct Gadget *ScreenGadget = screen->FirstGadget;
struct Gadget *DepthGadget = NULL;
while (ScreenGadget != NULL)
{
if ((ScreenGadget->GadgetType & GTYP_SYSTYPEMASK) == GTYP_SDEPTH)
{
/* We found the screen depth gadget */
DepthGadget = ScreenGadget;
}
ScreenGadget = ScreenGadget->NextGadget;
}
if ((DepthGadget != NULL) &&
(screen->MouseY < DepthGadget->Height) &&
(screen->MouseX > (screen->Width - DepthGadget->Width)))
{
/* Discard event, we'll do the processing ourselves */
ev->ie_Class = IECLASS_NULL;
/* Call main task to process it */
Signal (YakTask, depthscreensigflag);
}
}
else
{
/* A new window will get activated, so remember it
* only if it is a non backdrop window
*/
if (!(win->Flags & WFLG_BACKDROP))
{
RememberActiveWindow(win);
}
}
}
}
}
break;
case IECLASS_DISKINSERTED:
blankcount = blanktimeout; /* reset blanking countdown */
if (blanked) /* turn off screen-blanking */
UnBlankScreen ();
break;
}
}
IMPORT ULONG secs, micros;
IMPORT UBYTE FRONT_DELAY, BACK_DELAY;
void
WindowToFrontHandler (void)
{
struct Window *win;
static ULONG lastfrontmicros = 0l;
static ULONG lastfrontsecs = 0l;
static UBYTE frontclicks = 0;
if (Window_To_Front.RequiredClicks >1)
{
if (DoubleClick(lastfrontsecs, lastfrontmicros, secs, micros))
{
frontclicks++;
}
else
{
frontclicks = 1;
}
lastfrontmicros = micros;
lastfrontsecs = secs;
}
else
{
frontclicks = 1;
}
if (frontclicks == Window_To_Front.RequiredClicks)
{
if (win = WindowUnderMouse())
{
mousescr = win->WScreen;
if (IsIncludedScreen (mousescr, Window_To_Front))
{
if (OkayToPop (win) &&
(!(Window_To_Front.Options & Opt_ExcludeWbWindow) || IsNotWbWindow (win)))
{
if (win->Flags & WFLG_WBENCHWINDOW)
{
/* Let some time for wb processing, otherwise
* there will be a big delay of 1 second or so
*/
Delay(FRONT_DELAY);
}
WindowToFront (win);
}
else
{
if (Window_To_Front.Options & Opt_ScreenToFront)
{
ScreenToFront (mousescr);
ActivateMouseWindow (SCREEN);
}
}
}
}
else
{
mousescr = ScreenUnderMouse();
if ((IsIncludedScreen ( mousescr, Window_To_Front )) &&
(Window_To_Front.Options & Opt_ScreenToFront))
{
MyScreenToFront(mousescr);
}
}
frontclicks = 0;
}
}
void
WindowToBackHandler (void)
{
struct Window *win;
static ULONG lastbackmicros = 0l;
static ULONG lastbacksecs = 0l;
static UBYTE backclicks = 0;
if (Window_To_Back.RequiredClicks >1)
{
if (DoubleClick(lastbacksecs, lastbackmicros, secs, micros))
{
backclicks++;
}
else
{
backclicks = 1;
}
lastbackmicros = micros;
lastbacksecs = secs;
}
else
{
backclicks = 1;
}
if (backclicks == Window_To_Back.RequiredClicks)
{
if (win = WindowUnderMouse())
{
mousescr = win->WScreen;
if (IsIncludedScreen ( mousescr, Window_To_Back ))
{
if (!(win->Flags & WFLG_BACKDROP) &&
(win->NextWindow || (win->WScreen->FirstWindow != win)))
{
if (win->Flags & WFLG_WBENCHWINDOW)
{
/* Let some time for wb processing, otherwise
* there will be a big delay of 1 second or so
*/
Delay(BACK_DELAY);
}
WindowToBack(win);
}
else
{
if (Window_To_Back.Options & Opt_ScreenToBack)
{
ScreenToBack (mousescr);
ActivateMouseWindow (SCREEN);
}
}
}
}
else
{
mousescr = ScreenUnderMouse();
if ((IsIncludedScreen ( mousescr, Window_To_Back )) &&
(Window_To_Back.Options & Opt_ScreenToBack))
{
MyScreenToBack(mousescr);
}
}
backclicks = 0;
}
}
void
ScreenCyclingHandler (void)
{
static ULONG lastcyclingmicros = 0l;
static ULONG lastcyclingsecs = 0l;
static UBYTE cyclingclicks = 0;
if (ScreenCycling.RequiredClicks >1)
{
if (DoubleClick(lastcyclingsecs, lastcyclingmicros, secs, micros))
{
cyclingclicks++;
}
else
{
cyclingclicks = 1;
}
lastcyclingmicros = micros;
lastcyclingsecs = secs;
}
else
{
cyclingclicks = 1;
}
if (cyclingclicks == ScreenCycling.RequiredClicks)
{
mousescr = ScreenUnderMouse();
if (IsIncludedScreen ( mousescr, ScreenCycling ))
{
/* ev->ie_Class = IECLASS_NULL; */
MyScreenToBack (mousescr);
}
cyclingclicks = 0;
}
}
/* close resources allocated for MainHandler */
void
EndMainHandler ()
{
/* DeleteCxObjAll works even with CxObj is NULL */
DeleteCxObjAll(clickobj);
FreeAudio ();
if (intuiopsigbit != -1)
FreeSignal (intuiopsigbit);
if (clicksigbit != -1)
FreeSignal (clicksigbit);
if (depthscreensigbit != -1)
FreeSignal (depthscreensigbit);
if (blankscreensigbit != -1)
FreeSignal (blankscreensigbit);
UnBlankScreen ();
}
/* open resources needed for MainHandler */
BOOL
InitMainHandler ()
{
if (((clicksigbit = AllocSignal (-1)) != -1) &&
((intuiopsigbit = AllocSignal (-1)) != -1) &&
((blankscreensigbit = AllocSignal (-1)) != -1) &&
((depthscreensigbit = AllocSignal (-1)) != -1) &&
AllocAudio ())
{
YakTask = FindTask(NULL);
clicksigflag = 1 << clicksigbit;
intuiopsigflag = 1 << intuiopsigbit;
blankscreensigflag = 1 << blankscreensigbit;
depthscreensigflag = 1 << depthscreensigbit;
clickobj = CxCustom (MainHandler, 0L);
AttachCxObj (broker, clickobj);
return TRUE;
}
EndMainHandler ();
return FALSE;
}
#endif
#if !defined(CONV)
/* open/close resources needed for one of the MouseCycling handlers */
static VOID
ToggleYakHandler (YakHandler *YH)
{
static IX tmpIX = {IX_VERSION,0, 0, 0, 0, 0, 0 }; /* declaring it as static saves some
* bytes for the intitalization code
*/
/* DeleteCxObjAll() works even with NULL argument */
DeleteCxObjAll(YH->CxObj);
YH->CxObj=NULL;
if (YH->State == YKHK_ACTIVE)
{
#ifdef PREFS
if ((YH->CxObj = CxFilter(NULL)) && !CompatibleParseIX(YH->KeyDef, &tmpIX))
{
/* For prefs we don't want to really set up a filter */
DeleteCxObj(YH->CxObj);
YH->CxObj=NULL;
}
else
PostError("%s:\n\"%s\"", getString(Invalid_hotkey_specif_ERR), YH->KeyDef);
#else
if ((YH->CxObj = CxFilter(NULL)) && !CompatibleParseIX(YH->KeyDef, &tmpIX))
{
CxObj *tmp_obj;
SetFilterIX(YH->CxObj, &tmpIX);
AttachCxObj(broker, YH->CxObj);
if (tmp_obj = CxSender(broker_mp, YH->Event))
{
AttachCxObj(YH->CxObj, tmp_obj);
if ((tmp_obj=CxTranslate(NULL)) && (tmpIX.ix_Code == IECODE_RBUTTON))
AttachCxObj(YH->CxObj, tmp_obj);
}
}
#endif
}
}
/* open/close resources needed for Mouse Cycling */
VOID
ToggleMouseCycling(VOID)
{
UBYTE i;
InitMouseCyclingPatterns();
for (i=0; i< NUM_HANDLERS ; i++)
{
ToggleYakHandler(&MouseCyclingHandlers[i]);
}
}
#endif